package com.baifendian;

import com.baifendian.config.CorsFilter;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@MapperScan("com.baifendian.dao.mapper")
public class MonitorApplication {

	@Bean
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}

	/**
	 *添加跨域的filter
	 * @return
	 */
	@Bean
	public FilterRegistrationBean addFilterRegistration() {
		FilterRegistrationBean registration = new FilterRegistrationBean();
		registration.setFilter(new CorsFilter());
		registration.addUrlPatterns("/*");
		registration.setName("crossFilter");
		registration.setOrder(1);
		return registration;
	}

	public static void main(String[] args) {
		SpringApplication.run(MonitorApplication.class, args);
	}
}
